package com.cswangdao.service.impl;

import com.cswangdao.domain.dto.LogPageDTO;
import com.cswangdao.domain.model.MarketLog;
import com.cswangdao.mapper.MarketLogMapper;
import com.cswangdao.result.PageResult;
import com.cswangdao.service.LogService;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class LogServiceImpl implements LogService {
    @Autowired
    private MarketLogMapper logMapper;


    @Override
    public PageResult<MarketLog> pageQueryInfo(LogPageDTO pageDTO) {
        try/*(SqlSession sqlSession = MybatisUtil.getSqlSession(true))*/{
           // MarketLogMapper logMapper = sqlSession.getMapper(MarketLogMapper.class);
            PageHelper.startPage(pageDTO.getPage(),pageDTO.getLimit());
            Page<MarketLog> logPage = logMapper.pageQueryInfo(pageDTO);
            PageResult<MarketLog> result = PageResult.result(logPage);
            return result;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}
